<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>留学生管理系统</title>
        <link rel="stylesheet" href="${path}/css/admin2.css">
        <style>
            #settime,#settime2{
                margin: 13% auto;
                padding: 10px;
                width: 450px;
                background: #fff;
            }
             #create-modal{
                margin: 15% auto;
                padding: 10px;
                width: 400px;
            }
            #cName,#sName{
            width:120px;
            height:40px;
            float:left;
            box-shadow: 0 1px 1px #d4d3d3;
			font: 16px/40px 'Microsoft YaHei';
			line-height: 40px;
			text-align: center;
			cursor: pointer;
           
            }
            .active{
            color: #ffffff;
			background-color: #007cbc;
			}
			#inner-border{
			margin-top:52px;
			}
			#fileupload-pannel{
			
			}
        </style>
        <script>
            var _current_item = "#adminScoreManage";
        </script>
        <script type="text/javascript" src="${path}/js/jquery.min.js"></script>
    </head>
    <body>
    <div id="above-mask">
        <div class="fileupload pannel hide" id="fileupload-pannel">
                <div class="close-container">
                    <a class="close" onclick="hide('#above-mask, #mask, #fileupload-pannel');">×</a>
                </div>
                <form action="${path}/adminUploadPreScore/uploadPreScore" method="post" enctype="multipart/form-data" name="fileForm">
                    <div style="margin-top: 30px;"> 上传文件：（支持Excel 97-2003 工作簿 .xls格式文件）</div>
                    <input id="fileCover" class="left" readonly="readonly" placeholder="导入excel文件" type="text" style="width: 280px; height: 22px;">
                    <button onclick="$('#uploadFile').click();return false;" style="background: #aaa">浏览文件</button>
                    <input type="file" name="uploadFile" required="required" id="uploadFile" style="display:none" onchange="$('#fileCover').val($(this).val());">
                    <div>
                        <button type="submit" style="display: block; margin: 0 auto;">提交</button> 
                    </div>
                </form>
            </div>
        
            <div class="pannel hide" id="create-modal">
                <div class="close-container">
                    <a class="close" onclick="hide('#mask, #above-mask, #create-modal')">&times;</a>
                </div>
               
                    <table id="payTab">			
                        <tr>
                            <td ><br />该课程是否创建补考？<br /><br />
                            <button style="width:60px;margin-left:10px" id="addtest"onclick="creat(this)">是</button>
                    		<button style="width:60px;margin-left:40px" onclick="hide('#mask, #above-mask, #create-modal')">否</button></td>
                        </tr>
                    </table>
                </form>
            </div>
            <div id="settime" class="pannel hide">
                <div class="close-container">
                    <a class="close" onclick="$('#mask, #above-mask, #settime').hide();">×</a>
                </div>
                <form action="${path}/scoreMana/changeTimeAll">
                    <label style="font-size: 18px;">成绩录入时间设定</label>
                    <table>
                        <tr>
                            <td>课程：</td>
                            <td>
                                <select id="theTermValue" name="thetermValue">
                                <option value="0">&nbsp;全部</option>
                                    <#if allTest??>
                                    <#list allTest as ts>
                                    <option value="${ts.courseNo}">&nbsp;${ts.courseName}</option>
                                    </#list>
                                    </#if>
                                </select>
                            </td>
                        </tr>
                        <tr><td>学期：</td>
                        <td><select id="setSel" name="setSel">
                        <#if termValues??>
                        <#list termValues as tv>
                        <option>${tv.termValue}</option>
                        </#list>
                        </#if>
                        </select>
                        </td>
                        </tr>
                        <tr><td>最新截止时间：</td>
                            <td><input type="text" style="width:188px;height:30px" class="Wdate" id="changeTime" name="changeTime" onClick="WdatePicker({dateFmt:'yyyy-MM-dd'})" required="required"></td>
                        </tr>
                        <tr><td></td>
                            <td><button type="button" onclick="allTime()">确定</button></td>
                        </tr>

                    </table>
                </form>
            </div>
            <div id="settime2" class="pannel hide">
                <div class="close-container">
                    <a class="close" onclick="$('#mask, #above-mask, #settime2').hide();">×</a>
                </div>
                
                    <label style="font-size: 18px;">单条信息修改</label>
                    <form>
                        <input type="hidden" id="uuid2" name="uuid">
                        <table>
                       
                            <tr>
                                <td>学期：<input type="hidden" id="termValue2" name="termValue"></td>
                                <td id="termValue3"></td>
                            </tr>
                            <tr>
                                <td>课程名：<input type="hidden" id="courseName2" name="courseName"></td>
                                <td id="courseName3"><input type="txt" name="wu" value="${aNo!}"></td>
                            </tr>
                            <tr>
                                <td>课程编号：<input type="hidden" id="courseNo2" name="courseNo"></td>
                                <td id="courseNo3"></td>
                            </tr>
                            <tr><td>最新截止时间：</td>
                                <td><input type="text" style="width:188px;height:30px" id="changeTime2" class="Wdate" name="changeTime2" onClick="WdatePicker({dateFmt:'yyyy-MM-dd'})" required="required"></td>
                            </tr>
                            <tr><td></td>
                                <td><button onclick="singalChangeTimeClose();" id="testSize">确定</button></td>
                            </tr>
                        </table>
                    </form>
            </div>
        </div>
        <div id="mask"></div>
        <div id="header"></div>
        <div id="main">
            <div id="side-menu"></div>
            <div id="container">
            <div style="position:absolute;top:12px;margin-left:25px;">
                 <div id="cName" class="active">按课程名查看</div>
                 <div id="sName">按学生名查看</div>
              </div>
                <div id="inner-border">
                <!--  按课程名查看 -->
                    <div class="manage">
                        <div class="c1">
                            <span class="c2">学期</span>
                            <select class="c5" id="termValue">
                                <option value="0">&nbsp;全部</option>
                                <#if termValues??>
                                <#list termValues as ts>
                                <option value="${ts.termValue}">&nbsp;${ts.termValue}</option>
                                </#list>
                                </#if>
                            </select>
                            <span class="c2">课程名</span>
                            <select class="c5" id="course">
                                <option value="0">&nbsp;全部</option>
                                <#if allCourse?exists>
                                <#list allCourse as ac>
                                <option value="${ac.courseNo}">&nbsp;${ac.courseName}</option>
                                </#list>
                                </#if>
                            </select>
                            <span class="c2">教师</span>
                            <select class="c5" id="teacher">
                                <option value="0">&nbsp;全部</option>
                                <#if allTeacher?exists>
                                <#list allTeacher as at>
                                <option value="${at.tNo}">&nbsp;${at.tName}</option>
                                </#list>
                                </#if>
                            </select>
                            <button type="button" style="width:80px" onclick="ajaxsearch()">确定</button>
                            <button type="button" style="width:80px" onClick="$('#mask, #above-mask, #settime').show()">时间设定</button>
                            <!-- <button type="button" style="width:120px" onclick="window.location.href ='${path}/adminScoreHistoryManage/index'">查看历史成绩</button>
                             --><button type="button" style="width:130px" onclick="show('#mask, #above-mask, #fileupload-pannel')">学生历史成绩导入</button>                          
                        	<button type="button" style="width:100px" onclick="window.location.href = '${path}/adminUploadPreScore/fileDownload'">模版下载</button> 
                           
                            </div><br /><br />
                        <!-- -->
                        <div>
                        
                            <table class="table table-bordered" id="scoretable">
                                <thead>
                                    <tr>
                                    	<th>学期</th>
                                        <th>课程名</th> 
                                        <th>教师</th>
                                        <th>截止日期</th>
                                        <th>状态</th>
                                        <th>操作</th>
                                    </tr></thead>
                                <tbody>
                                    <#if allTTT??>
                                    <#list allTTT as ttt>
                                    <tr>
                                   		<td>${ttt.termValue}</td>
                                   		 <#if ttt.testType=="1">
                                        <td><a href="${path}/scoreMana/stuScore?testNo=${ttt.testNo}">
                                        ${ttt.courseName!}
                                        </a></td>
                                         <#else>
                                         <td><a href="${path}/scoreMana/lookBukaoStuGrades?testNo=${ttt.testNo}&uuid=${ttt.uuid}">
                                        ${ttt.courseName!}
                                        </a></td>
                                        </#if>
                                        <td>
                                        ${ttt.tName!}
                                        </td>
                                        <td>
                                           ${ttt.endDate!}
                                        </td>
                                        <td>
                                           ${ttt.status!}   
                                        </td>
                                       
                                         <td>
                                          <#if ttt.testSize==1> 
                                         <#if ttt.testLock=="0"||ttt.testLock=="3">
                                           	<button type="button" style="width:100px" onclick="window.location.href = '${path}/scoreMana/exportGrade?testNo=${ttt.testNo}'" ${ttt.statusExport!}>导出Excel</button>&nbsp;|&nbsp;
                                           	
                                           	<input type="image" src="${path}/img/kai.png" onClick="setForm('${ttt.uuid}','${ttt.termValue}','${ttt.courseNo}','${ttt.courseName}','${ttt.testNo}','1');$('#mask, #above-mask, #settime2').show();">
                                           <#else>
                                           	<button type="button" style="width:100px" onclick="window.location.href = '${path}/scoreMana/exportGrade?testNo=${ttt.testNo}'" ${ttt.statusExport!}>导出Excel</button>&nbsp;|&nbsp;
                                           	<input type="image" src="${path}/img/bi.png" onClick="singalChangeTimeOpen('${ttt.testNo}')">
                                           </#if>
                                            <#elseif ttt.testSize==2>
                                           <#if ttt.testLock=="0"||ttt.testLock=="3">
                                           
                                           	<button type="button" style="width:100px" onclick="window.location.href = '${path}/scoreMana/exportGrade?testNo=${ttt.testNo}'" ${ttt.statusExport!}>导出Excel</button>&nbsp;|&nbsp;
                                           	<input type="image" src="${path}/img/kai.png" onClick="setForm('${ttt.uuid}','${ttt.termValue}','${ttt.courseNo}','${ttt.courseName}','${ttt.testNo}','2');$('#mask, #above-mask, #settime2').show();">
                                           <#else>
                                          
                                           	<button type="button" style="width:100px" onclick="window.location.href = '${path}/scoreMana/exportGrade?testNo=${ttt.testNo}'" ${ttt.statusExport!}>导出Excel</button>&nbsp;|&nbsp;
                                           	
                                           	<#if ttt.status="正考已录入">
                                            &nbsp;&nbsp;
                                           	<#else>
                                           	<input type="image" src="${path}/img/bi.png" onClick="singalChangeTimeOpen('${ttt.testNo}')">
                                           </#if>
                                           </#if> 
                                           	<#else>
                                           	<!-- <button type="button" style="width:100px" onclick="window.location.href = '${path}/scoreMana/exportGrade?testNo=${ttt.testNo}'">导出Excel</button>&nbsp;|&nbsp; -->
                                           	历史成绩
                                          </#if>  
                                        </td>
                                    </tr>
                                    </#list>
                                    </#if>
                                </tbody>	
                            </table>

                            <!-- <button type="button" style="width:130px" onclick="show('#mask, #above-mask, #fileupload-pannel')">查看历史成绩</button>  -->                          
                        	<!-- <button type="button" style="width:100px" onclick="window.location.href = '${path}/adminUploadPreScore/fileDownload'">模版下载</button> -->                                                   
                        </div>
                    </div>
                    
                   <!--  按学生名查看 -->
                   <div id="stu_div" style="display:none">
                   <br>
                   <table class="table table-bordered" id="stutable">
                                <thead>
                                    <tr>
                                    	<th>学号</th>
                                    	<th>护照号</th>
                                        <th>姓</th> 
                                        <th>名</th>
                                        <th>班级</th>
                                        <th>专业</th>
                                        <th>操作</th>
                                    </tr></thead>
                                <tbody>
                                </tbody>
                                </table>
                    </div>
                    <!--  按学生名查看 -->
                </div>
            </div>
        </div>
        <div id="footer"></div>
        <script type="text/javascript" src="${path}/js/admin-main-appearance.js"></script>

        <!-- DataTables JavaScript -->
        <script src="${path}/bower_components/datatables/media/js/jquery.dataTables.min.js"></script>
        <script src="${path}/bower_components/datatables-plugins/api/fnGetHiddenNodes.js"></script>
        <script src="${path}/bower_components/datatables-plugins/api/fnGetTd.js"></script>
        <script src="${path}/bower_components/datatables-plugins/api/fnGetTds.js"></script>
        <script src="${path}/bower_components/datatables-plugins/api/fnGetColumnData.js"></script>
        <script src="${path}/bower_components/datatables-plugins/integration/bootstrap/3/dataTables.bootstrap.min.js"></script>
        <script type="text/javascript" src="${path}/js/lanrenzhijia.js"></script>
        <script type="text/javascript" src="${path}/js/My97DatePicker/WdatePicker.js"></script>


        <script type="text/javascript">
                                                $(document).ready(function() {
                                                $('#scoretable').DataTable({
                                                responsive: true,
                                                        ordering: false,
                                                        searching: false,
                                                        "bLengthChange": false,
                                                        "bRetrieve": true,
                                                        "bFilter": true//过滤功能

                                                });
                                                
                                                if("${uploadInf!}"!=""){
                                                alert("${uploadInf!}");}
                                                });
        </script>
        <script>
            function singalChangeTimeOpen(testNo){
            changeTime="changeTime";
            alert(testNo);
            $.ajax({
            type:"post",
                    url:'${path}/scoreMana/adminLock',
                    data:{
                            testNo:testNo,
                            changeTime:changeTime,
                    },
                    datatype:"json",
                    success:function(data){
                    //alert(JSON.stringify(data));
                        //alert("success");
                        window.location.href = "${path}/scoreMana/index";
                    }
            }); 
            }
            
            /* 全部时间设定 */
            function allTime(){
               var theTermValue=document.getElementById("theTermValue").value;
               var setSel=document.getElementById("setSel").value;
               var changeTime=$("#changeTime").val();
            
               
                 $.ajax({
                	type:"post",
                	url:'${path}/scoreMana/changeTimeAll',
                	datatype:"json",
                	data:{
                		thetermValue:theTermValue,
                		setSel:setSel,
                		changeTime:changeTime,
                	},    
                	
            	success:function(data){
                $('#mask, #above-mask, #settime').hide();
               // alert("success"); 
               // alert(JSON.stringify(data));
                getdata(data);
            }
            });
           
        
            }
            
            /* 单条记录修改 */
            function singalChangeTimeClose(){
                if($('#changeTime2').val() == "" || $('#changeTime2').val() == null ){
                    alert("请输入日期");
                    return;
                }
                var testNo=$("#testSize").attr("testNo");
                //alert($('#changeTime2').val());
                 $.ajax({
                	type:"post",
                	url:'${path}/scoreMana/adminLock',
                	datatype:"json",
                	data:{
                		testNo:testNo,
                		changeTime2:$('#changeTime2').val(),
                	},    
                	
            	success:function(data){
                $('#mask, #above-mask, #settime2').hide();
                //alert("success"); 
                //alert(JSON.stringify(data));
                getdata(data);
            }
            });
           
        
            }
            
            
            function setForm(uuid, termValue,courseNo,courseName,testNo,testSize){
            changeTime2="changeTime2";
                $("#uuid2").val(uuid);
                $("#termValue2").val(termValue);
                $("#termValue3").html(termValue);
                $("#courseNo2").val(courseNo);
                $("#courseNo3").html(courseNo);
                $("#courseName2").val(courseName);
                $("#courseName3").html(courseName);
                $("#testSize").attr("testSize",testSize);
                $("#testSize").attr("testNo",testNo);
     
               
            }
            
            function addTest(node){
            	var uuid = node.getAttribute("uuid");
            	//alert(uuid);
            	$("#addtest").attr("uuid",uuid);
            	show('#mask, #above-mask, #create-modal');
            }
            
           /*  自动创建补考 */
            function creat(node){
            	var uuid = node.getAttribute("uuid");
            	//alert(uuid);
            	 $.ajax({
          			type:"post",
                    url:'${path}/scoreMana/addTest',
                    data:{
                            uuid:uuid,
                    },
                    datatype:"json",
                     success:function(data){
                      window.location.href = "${path}/scoreMana/index";
                    }
                    });
            }
            
            /*获取select的value*/
            function getSelectedValue(select){
        	    for(var i=0; i<select.options.length; i++){
        	       	if(select.options[i].selected)
        	       		return select.options[i].innerHTML;
                }
        	    return null;
            }

            function course(uuid,flag){
            $.ajax({
            type:"post",
                    url:'${path}/scoreMana/scoreDetail',
                    data:{
                            uuid:uuid,
                            flag:flag,
                    },
                    datatype:"json",
                    success:function(data){
                    window.location.href="${path}/scoreMana/scoreStu";
            }
            });
            }
            
            function ajaxsearch(){
            $.ajax({
            type:"post",
                    url:'${path}/scoreMana/tjsearch',
                    data:{
                             termValue:$('#termValue').val(),
                            course:$('#course').val(),
                            teacher:$('#teacher').val(), 
                    },
                    datatype:"json",
                    success:function(data){
                    //alert("success");
                    //alert(data);
                   // alert(JSON.stringify(data));
                    //alert(data[i]["classroomNo"]);
                   getdata(data);
                    }
            });
            }

             function getdata(data) {
            	 //alert(JSON.stringify(data));
                $('#scoretable').dataTable().fnClearTable();
                 for (var i = 0; i < data.length; i++){
                    var a = data[i]["uuid"];
                    var uid="'"+data[i]["uuid"]+"'";
                    var t=data[i]["testNo"];
                    var tv="'"+data[i]["termValue"]+"'";
                    var cno="'"+data[i]["courseNo"]+"'";
                    var cna="'"+data[i]["courseName"]+"'";
                     var tn="'"+data[i]["testNo"]+"'";
                     var statusLock = data[i]["statusLock"];
                     var statusExport = data[i]["statusExport"];
                    var cmd="'"+"#mask, #above-mask, #settime2"+"'";
                    //alert(data[i]["statusLock"]);
                    if (data[i]["testSize"] == 1){
                    
                    if (data[i]["testLock"] == 0||data[i]["testLock"] == 3){																																								                                           
                        $('#scoretable').dataTable().fnAddData([data[i]["termValue"],'<a href="${path}/scoreMana/stuScore?testNo=' + t + '">'+data[i]["courseName"]+'</a>', data[i]["tName"],data[i]["endDate"],data[i]["status"],  '<button type="button" '+statusExport+' style="width:100px" onclick="window.location.href=&quot;${path}/scoreMana/exportGrade?testNo=' + t + '&quot;">导出Excel</button>&nbsp;|&nbsp;<input type="image" src="${path}/img/kai.png"  onClick="setForm('+uid+','+tv+','+cno+','+cna+','+tn+',&quot;1&quot;);$('+cmd+').show();"/>']);
                        var id = data[i]["id"];
                        }else{
                        $('#scoretable').dataTable().fnAddData([data[i]["termValue"],'<a href="${path}/scoreMana/stuScore?testNo=' + t + '">'+data[i]["courseName"]+'</a>', data[i]["tName"],data[i]["endDate"],data[i]["status"], '<button type="button" '+statusExport+' style="width:100px" onclick="window.location.href=&quot;${path}/scoreMana/exportGrade?testNo=' + t + '&quot;">导出Excel</button>&nbsp;|&nbsp;<input type="image" src="${path}/img/bi.png"  onClick="singalChangeTimeOpen('+tn+');"/>']);
                        var id = data[i]["id"];
                        }
                        // alert(data[i]["startLesson"]);
                    }
                    
                    else if (data[i]["testSize"] == 2){
                       if (data[i]["testLock"] == 0||data[i]["testLock"] == 3){
                        $('#scoretable').dataTable().fnAddData([data[i]["termValue"],'<a href="${path}/scoreMana/stuScore?testNo=' + t + '">'+data[i]["courseName"]+'</a>', data[i]["tName"],data[i]["endDate"],data[i]["status"],  '<button type="button" '+statusExport+' style="width:100px" onclick="window.location.href=&quot;${path}/scoreMana/exportGrade?testNo=' + t + '&quot;">导出Excel</button>&nbsp;|&nbsp;<input type="image" src="${path}/img/kai.png"  onClick="setForm('+uid+','+tv+','+cno+','+cna+','+tn+',&quot;2&quot;);$('+cmd+').show();"/>']);
                        var id = data[i]["id"];
                        }
                        
                        else{
                        if(data[i]["status"]=="正考已录入"){
                        $('#scoretable').dataTable().fnAddData([data[i]["termValue"],'<a href="${path}/scoreMana/stuScore?testNo=' + t + '">'+data[i]["courseName"]+'</a>', data[i]["tName"] ,data[i]["endDate"],data[i]["status"], '<button type="button" '+statusExport+' style="width:100px" onclick="window.location.href=&quot;${path}/scoreMana/exportGrade?testNo=' + t + '&quot;">导出Excel</button>&nbsp;|&nbsp;&nbsp;&nbsp;']);
                        var id = data[i]["id"];
                        }else{
                        $('#scoretable').dataTable().fnAddData([data[i]["termValue"],'<a href="${path}/scoreMana/stuScore?testNo=' + t + '">'+data[i]["courseName"]+'</a>', data[i]["tName"] ,data[i]["endDate"],data[i]["status"], '<button type="button" '+statusExport+' style="width:100px" onclick="window.location.href=&quot;${path}/scoreMana/exportGrade?testNo=' + t + '&quot;">导出Excel</button>&nbsp;|&nbsp;<input type="image" src="${path}/img/bi.png"  onClick="singalChangeTimeOpen('+tn+');"/>']);
                        var id = data[i]["id"];
                        }
                    }
                    }
                    
                    else{
                    $('#scoretable').dataTable().fnAddData([data[i]["termValue"],'<a href="${path}/scoreMana/stuScore?testNo=' + t + '">'+data[i]["courseName"]+'</a>',"" ,"","","历史成绩"]);
                        var id = data[i]["id"];
                    }
                } 
                //alert(1);
            }

			//名称切换
            $("#sName").on("click",function(){
            	$("#sName").addClass("active");
            	$("#cName").removeClass("active");
            	$('#stutable').DataTable({
            	 		responsive: true,
                   	 	ordering: false,
                    	searching: true,
                    	"bLengthChange": false,
                    	"bRetrieve": true,
                    	"bFilter": true//过滤功能
            	 		});
            	
            	 $.ajax({
            		type:"post",
                    url:'${path}/scoreMana/lookStuInfo',
                    data:{ 
                    },
                    datatype:"json",
                    success:function(data){
                    //alert("success");
                    //alert(data);
                    //alert(JSON.stringify(data));
                    //alert(JSON.parse(JSON.stringify(data)) )
                    $('#stutable').dataTable().fnClearTable();
                    for (var i = 0; i < data.length; i++){
                    t=data[i]["passportNo"];
                    //alert(t);
                    var link = "window.location.href ='${path}/adminSingleStuScoreManage/index?passportNo="+t+"'";
                    //alert(link);
                    $('#stutable').dataTable().fnAddData([data[i]["sNo"],data[i]["passportNo"],data[i]["lastName"],data[i]["firstName"],data[i]['class'],data[i]["majorName"],'<button class="edit" passport="'+t+'" onclick="'+link+'">查看</button>']);
                    }
                    
                    //alert(data[i]["lastName"]);
                    $("#stu_div").css("display","block");
            	 	$(".manage").css("display","none");
                    }
            }); 
            	
            	 
            	 
                    
            	 
            	 
            	 
            })
            
             $("#cName").on("click",function(){
            	$("#cName").addClass("active");
            	$("#sName").removeClass("active");
            	$("#stu_div").css("display","none");
            	 $(".manage").css("display","block");
                        
            })
        </script>
    </body>
</html>
